package com.tianhui.consignortwofei.other.auth.recognition.recognitionResultProcess;

import android.text.TextUtils;

import com.baidu.ocr.sdk.model.BankCardResult;
import com.fgs.common.utils.LogUtil;
import com.tianhui.consignortwofei.mvp.model.enty.bankCard.BankCardInfo;

/**
 * @author fgs
 * @date 2020/11/16
 * @description
 **/
public class BankCardOcrResultProcess {
    public BankCardInfo getBankCardOcrResult(BankCardResult result) {

        BankCardInfo bankCardInfo = new BankCardInfo();
        if (result == null) {
            return bankCardInfo;
        }
        if (result.getBankCardNumber() != null) {
            String number = result.getBankCardNumber();
            number = formatBankCardNumber(number);
            bankCardInfo.bankcardno = number;
            LogUtil.print("银行卡号：", number);
        }
        return bankCardInfo;
    }

    //银行卡号去掉空格
    private String formatBankCardNumber(String bankCardNumber) {
        String result = "";
        if (!TextUtils.isEmpty(bankCardNumber)) {
            result = bankCardNumber.replaceAll(" ", "");
        }
        return result;
    }
}
